<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js" type="application/javascript"
  ></script>
</head>
<body>
<div id="app">
  <!-- 监听子组件事件，方式1 -->
  <!-- 通过v-on/@监听子组件的事情，属于父子通信 -->
  <!--  <el-button @click="onClick"></el-button>-->
  <!-- 监听子组件事件，方式2-->
  <!--  通过dom事件冒泡-->
  <!--  <div @click="onClick">
      <el-button></el-button>
    </div>-->
  <!-- .native属于事件冒泡语法糖 -->
  <el-button @click.native="onClick"></el-button>
</div>
</body>
<script>
  /*  Vue.component('el-button', {
      template: `
      <div><button @click="$emit('click')">按钮</button></div>
      `
    })*/
  Vue.component('el-button', {
    template: `
    <div><button>按钮</button></div>
    `
  })
  new Vue({
    data() {
      return {
        msg: 'hello vue'
      }
    },
    el: '#app',
    methods: {
      onClick() {
        console.log('点击了')
      }
    }
  })
</script>
</html>
